﻿using System;
using Windows.UI.Xaml.Data;

namespace Antares.Converters
{
    public class StringToDateTimeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            return value + string.Empty == string.Empty ? (object) null : DateTime.Parse(value.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            //var sp = date.Split(new[] { '/', ' ', '-' });
            //switch (CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToLower())
            //{
            //    case "dd/mm/yyyy":
            //        date = System.Convert.ToDateTime(value).ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
            //        break;
            //    default:
            //        date = System.Convert.ToDateTime(value).ToString();
            //        break;
            //}
            return DateTime.Parse(value.ToString()).ToString();
        }
    }
}
